/**
 * 页面渲染顺序与代码模块顺序一致
 * 模块名不能重复
 */
module.exports.swiper1 = {
  name: 'swiper1',
  data: ['../../images/swiper1.jpg', '../../images/swiper2.jpg', '../../images/swiper3.jpg']
}
module.exports.entry1 = {
  name: 'entry1',
  data: [
    { src: '../../images/list1.png', title: '早晚市', url:'/pages/details/details'},
    { src: '../../images/list2.png', title: 'top榜', url: '/pages/details/details' },
    { src: '../../images/list3.png', title: '满99减50', url: '/pages/details/details' },
    { src: '../../images/list4.png', title: '抢鲜购', url: '/pages/details/details' },
    { src: '../../images/list5.png', title: '跨年购', url: '/pages/details/details'}]
}

module.exports.module_2 = {
  name: 'module-2',
  data: {
    src: '../../images/mindex.jpg'
  }
}

module.exports.module_1 = {
  name: 'module-1',
  data: generateMoudle_1_data()
}

module.exports.module_4 = {
  name: 'module-2',
  data: {
    src: '../../images/mindex.jpg'
  }
}

module.exports.module_3 = {
  name: 'no-more-goods',
  data: { text: '没有更多商品' }
}




/**
 * 生成module-1模块所需数据
 * @return result {{array}}
 */
function generateMoudle_1_data(){
  const srcList = ['../../images/goods1.jpg', '../../images/goods2.jpg', '../../images/goods3.jpg'];
  const goods_abstract = ['Mixxtail魅夜 专业鸡尾酒 蓝色幻想鸡尾酒（露酒）310ml', '曼可顿面包 香蕉牛奶味 68g','康师傅蜂蜜绿茶 500ml'];
  let result = [];

  function randomSelect(arr) {
    const num = Math.floor(Math.random() * arr.length);
    return arr[num];
  }

  for(let i=0;i<12;i++){
    const price = (Math.random() * 20).toFixed(2);
    const discounted_price = (price * 0.5).toFixed(2);
    result.push({
      src: randomSelect(srcList),
      goods_abstract: randomSelect(goods_abstract),
      price: price,
      discounted_price: (price*0.5).toFixed(2),
      discounted:true
    })
  }
  return result;
}
